package com.jswlw.controller.api;

import com.jswlw.common.BaseApiResponse;
import com.jswlw.controller.api.req.order.SaveOrderRequest;
import com.jswlw.controller.api.resp.OrderListResponse;
import com.jswlw.controller.api.resp.SaveOrderResponse;
import com.jswlw.controller.api.resp.UserInfoResponse;
import com.jswlw.controller.api.wrapper.OrderWrapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author 吴维斌 E-mail:wuweibin0817@163.com
 * @version 创建时间：${date} ${time}
 */
@Api(tags = "订单管理")
@RestController
@RequestMapping("/api/order")
public class ApiOrderController {

    @Autowired
    OrderWrapper wrapper;

    @ApiOperation(value = "订单列表", notes = "订单列表")
    @ApiResponse(code = 200, message = "OK", response = OrderListResponse.class)
    @GetMapping("orderList")
    public OrderListResponse orderList(
            @RequestParam(value = "devId") String devId,
            @RequestParam(value = "payStatus", required = false) Integer payStatus) {
        return wrapper.orderList(devId,payStatus);
    }

    @ApiOperation(value = "保存订单", notes = "保存订单")
    @ApiResponse(code = 200, message = "OK", response = SaveOrderResponse.class)
    @PostMapping("saveOrder")
    public SaveOrderResponse saveOrder(@RequestBody SaveOrderRequest request) {
        return wrapper.saveOrder(request);
    }
}
